<%--
  Created by IntelliJ IDEA.
  User: 宋晓博
  Date: 2022/1/1
  Time: 17:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<html>
<head>
    <title>欢迎登录</title>
    <link type="text/css" rel="stylesheet" href="/static/bootstrap-3.4.1-dist/css/bootstrap.css"/>
    <link type="text/css" rel="stylesheet" href="/static/css/logIn.css"/>
    <style type="text/css">
        .wai{padding-top: 50px;}
    </style>
</head>
<body>
<script type="text/javascript" src="/static/bootstrap-3.4.1-dist/js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="/static/bootstrap-3.4.1-dist/js/bootstrap.js"></script>
<c:import url="header.jsp"></c:import>
<div class="container">
    <div class="col-md-4 col-md-offset-4 wai">
        <form class="form-horizontal" action="/user/tologIn" method="post">
            <div class="form-group">
                <label for="username" class="col-md-3 control-label">用户名</label>
                <div class="col-md-9">
                    <input type="text" class="form-control" id="username" name="username" placeholder="请输入用户名">
                </div>
            </div>
            <div class="form-group">
                <label for="password" class="col-md-3 control-label">密码</label>
                <div class="col-md-9">
                    <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码">
                </div>
            </div>
            <div class="form-group">
                <label for="unicode" class="col-md-3 control-label">验证码</label>
                <div class="col-md-9">
                    <input type="text" class="form-control" id="unicode" name="unicode" placeholder="请输入验证码">
                    <br>
                    <img src="/pic" id="pic">&nbsp;&nbsp;<a id="kanbuqin">看不清</a>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-3 col-sm-9">
                    <div class="radio">
                        <label><input type="radio" name="rememberme" value="yes">记住密码</label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-3 col-sm-9">
                    <button type="submit" class="btn btn-primary btn-lg  btn-block">登录</button>
                </div>
            </div>
        </form>
        <h4 class="h4">info：${username},${error}</h4>
        <h3 class="time"></h3>
    </div>
</div>
</body>
<script type="text/javascript">
 $(function () {
    function newtime(){
        $(".time").html(new Date().toLocaleString());
    }
     t=setInterval(newtime,500);
    $("#username").change(function() {
        var name=$("#username").val();
        $.ajax({
            url:"/user/autoInsert",
            data:{userName:name},
            type:"post",
            dataType:"text",
            success:function (data) {
                if(data!=null){
                    $("#password").val(data);
                    //再将数据回填到密码框
                    console.log("自动填充了密码:" + data);
                }
            }
        })
    });
    $("#kanbuqin").click(function () {
        $("#pic").attr("src","pic?m="+Math.random());
        return false;
    })
})
</script>
</html>
